﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
namespace CardsServer.Tools
{
    public static class MyLog
    {
        public static void writeErrorToLog(string message)
        {

            string isLog = MyConfig.getAppValue("isLog");
            if (!string.IsNullOrEmpty(isLog))
            {
                EventLog eventLog = null;

                if (isLog == "true")
                {
                    if (!(EventLog.SourceExists(MyConfig.getAppValue("AppName"))))
                    {
                        EventLog.CreateEventSource(MyConfig.getAppValue("AppName"), MyConfig.getAppValue("CorName"));
                    }
                    if (eventLog == null)
                    {
                        eventLog = new EventLog(MyConfig.getAppValue("CorName"));
                        eventLog.Source = MyConfig.getAppValue("AppName");
                    }


                    eventLog.WriteEntry(message, System.Diagnostics.EventLogEntryType.Error, 100, 100, null);

                }


            }
        }




        public static void writeInfoToLog(string message)
        {
            string isLog = MyConfig.getAppValue("isLog");
            if (!string.IsNullOrEmpty(isLog))
            {
                EventLog eventLog = null;

                if (isLog == "true")
                {
                    if (!(EventLog.SourceExists(MyConfig.getAppValue("AppName"))))
                    {
                        EventLog.CreateEventSource(MyConfig.getAppValue("AppName"), MyConfig.getAppValue("CorName"));
                    }
                    if (eventLog == null)
                    {
                        eventLog = new EventLog(MyConfig.getAppValue("CorName"));
                        eventLog.Source = MyConfig.getAppValue("AppName");
                    }


                    eventLog.WriteEntry(message, System.Diagnostics.EventLogEntryType.Information, 100, 100, null);

                }


            }
        }
    }
}
